package top.jandmla.shop.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.jandmla.shop.bean.User;
import top.jandmla.shop.dao.UserMapper;
import top.jandmla.shop.service.UserService;

import javax.annotation.Resource;

/**
 * <p>
 *
 * </p>
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper mapper;


    public User getUserByName(String userId){
        if (StringUtils.isNotBlank(userId)){
            QueryWrapper<User> qw = new QueryWrapper<>();
            qw.select("id,userId,userName,userImage,userPhone");
            qw.eq("userId",userId);
            return mapper.selectOne(qw);
        }
        return null;
    }

    @Override
    public String getPasswordById(String userId) {
        if (StringUtils.isNotBlank(userId)){
            QueryWrapper<User> qw = new QueryWrapper<>();
            qw.select("password");
            qw.eq("userId",userId);
            return mapper.selectOne(qw).getPassword();
        }
        return null;
    }
}
